<?php
/*
 * 域名代购
 *
 */
class ProcurementAction extends BaseAction{
	public function index(){
            $purchase = M('Purchase');
            $ph_list = $purchase->where('`status` = 6 AND `is_show` = 1')->limit('0,14')->select();
            $this->assign('ph_list',$ph_list);
            if($_GET['d']){
                $this->assign('d',$_GET['d']);
            }
            $this->display();
	}
        public function add(){
             $domain = trim($_POST['domain']);
             $check_domain =  $this->top_domain($domain);
             $check_domain = explode('.', $check_domain);

            if($check_domain[1])
            {
                $purchase = M('Purchase');
                $data['staff_id']=$_SESSION['user']['staff_uid'];
                if($data['staff_id']){
                    $data['status'] = 1;
                }
                $data['uid']=$this->user_session['uid'];
                //if(empty ($this->user_session['uid']))$this->error('请先登录',U('Login/index'));
                if(empty ($this->user_session['uid'])){echo 4;die;}
                $data['uname']=$_SESSION['user']['nickname'];
                $data['add_time']= time();
                $data['domain']=$_POST['domain'];
                $data['buyers_price']=$_POST['buyers_price'];
                $data['message']=$_POST['message'];
                $data['type']=0;
                $row = $purchase->add($data);
                if($row){
//                    $this->success('增加代购成功',U('Account/pay'));
                    echo 1;die;
                }  else {
                    echo 2;die;
//                    $this->success('增加代购失败',U('Procurement/index'));
                }
                
            }else{
                echo 3;die;
//                $this->error('请输入正确的域名 ');
            }
            
            
            
        }
}